using System;
using System.Runtime.Serialization;
namespace Net35.Xrm.Sdk
{
	[DataContract(Name = "EntityReference", Namespace = "http://schemas.microsoft.com/xrm/2011/Contracts")]
	[Serializable]
	public sealed class EntityReference : IExtensibleDataObject
	{
		private string _logicalName;
		private string _name;
		private Guid _id;
		[NonSerialized]
		private ExtensionDataObject _extensionDataObject;
		[DataMember]
		public Guid Id
		{
			get
			{
				return this._id;
			}
			set
			{
				this._id = value;
			}
		}
		[DataMember]
		public string LogicalName
		{
			get
			{
				return this._logicalName;
			}
			set
			{
				this._logicalName = value;
			}
		}
		[DataMember]
		public string Name
		{
			get
			{
				return this._name;
			}
			set
			{
				this._name = value;
			}
		}
		public ExtensionDataObject ExtensionData
		{
			get
			{
				return this._extensionDataObject;
			}
			set
			{
				this._extensionDataObject = value;
			}
		}
		public EntityReference()
		{
		}
		public EntityReference(string logicalName, Guid id)
		{
			this._logicalName = logicalName;
			this._id = id;
		}
		public override bool Equals(object obj)
		{
			EntityReference entityReference = obj as EntityReference;
			return entityReference != null && (this == entityReference || (this._id.Equals(entityReference._id) && string.Compare(this._logicalName, entityReference._logicalName, StringComparison.Ordinal) == 0));
		}
		public override int GetHashCode()
		{
			if (!string.IsNullOrEmpty(this._logicalName))
			{
				return this._logicalName.GetHashCode() ^ this._id.GetHashCode();
			}
			return 0;
		}
	}
}
